package com.hspedu.list_;

import java.util.*;

public class ListFor {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        //List 接口的实现子类， Vector LinkedList
//        List list = new ArrayList();
        List list = new LinkedList();
//        List list = new Vector();

        list.add("刘金涛");
        list.add("想吃");
        list.add("小炒肉");
        list.add("鱼香肉丝");

        System.out.println("====迭代器====");
        // 1.迭代器
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object obj =  iterator.next();
            System.out.println("obj=" + obj);
        }


        System.out.println("====增强 for====");
        // 2.增强 for
        for (Object o : list) {
            System.out.println("o=" + o);
        }

        System.out.println("====普通 for====");
        for (int i = 0; i < list.size(); i++) {
            System.out.println("对象=" + list.get(i));
        }
    }
}
